﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using QuanLyVanBanBUS;

public partial class QLVB_User_VanBanChuaDuyet : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            layDanhSachLoaiVanBan();

            layDanhSachHinhThuc();

            layDanhSachTinhChat();

            layDanhSachNoiPhatHanh();
            if (cmbMaNoiPhatHanh.Items.Count > 0)
            {
                cmbMaNoiPhatHanh.SelectedIndex = 0;

                layThongTinChiTietMaNoiPhatHanh();
            }

            //Load len NoiNhanVanBan
            layDanhSachPhong();

            //Lay SoVanBanCanTim
            txtSoVanBanCanTim.Text = string.Empty;
            txtSoVanBanCanTim.Text = (String)Session["SoVanBanCanTim"];
            hfSoVanBanCanTim.Value = (String)Session["SoVanBanCanTim"];
        }
    }

    protected void layDanhSachLoaiVanBan()
    {
        LoaiVanBanBUS lvbBUS = new LoaiVanBanBUS();

        cmbMaLoaiVanBan.DataSource = lvbBUS.layDanhSachLoaiVanBan();
        cmbMaLoaiVanBan.DataTextField = "TenLoaiVanBan";
        cmbMaLoaiVanBan.DataValueField = "MaLoaiVanBan";
        cmbMaLoaiVanBan.DataBind();
    }
    protected void layDanhSachHinhThuc()
    {
        HinhThucBUS htBUS = new HinhThucBUS();

        cmbMaHinhThuc.DataSource = htBUS.layDanhSachHinhThuc();
        cmbMaHinhThuc.DataTextField = "TenHinhThuc";
        cmbMaHinhThuc.DataValueField = "MaHinhThuc";
        cmbMaHinhThuc.DataBind();
    }
    protected void layDanhSachTinhChat()
    {
        TinhChatBUS tcBUS = new TinhChatBUS();

        cmbMaTinhChat.DataSource = tcBUS.layDanhSachTinhChat();
        cmbMaTinhChat.DataTextField = "TenTinhChat";
        cmbMaTinhChat.DataValueField = "MaTinhChat";
        cmbMaTinhChat.DataBind();
    }
    protected void layDanhSachNoiPhatHanh()
    {
        NoiPhatHanhBUS nphBUS = new NoiPhatHanhBUS();

        cmbMaNoiPhatHanh.DataSource = nphBUS.layDanhSachNoiPhatHanh();
        cmbMaNoiPhatHanh.DataTextField = "TenNoiPhatHanh";
        cmbMaNoiPhatHanh.DataValueField = "MaNoiPhatHanh";
        cmbMaNoiPhatHanh.DataBind();
    }
    protected void layDanhSachPhong()
    {
        PhongBUS pBUS = new PhongBUS();

        gvPhongNhanVanBan.DataSource = pBUS.layDanhSachPhong();
        gvPhongNhanVanBan.DataBind();
    }
    protected void lbtnChonFile_Click(object sender, EventArgs e)
    {
        Session["SoVanBanCanTim"] = txtSoVanBanCanTim.Text;
        
        Session["SoVanBan"] = txtSoVanBan.Text;

        Session["TenVanBan"] = txtTenVanBan.Text;

        Session["NgayHieuLuc"] = txtNgayHieuLuc.Text;

        Session["NgayHetHieuLuc"] = txtNgayHetHieuLuc.Text;

        Session["NoiDungVanBan"] = txtNoiDungVanBan.Text;

        Session["NoiDungButPhe"] = txtNoiDungButPhe.Text;

        Response.Redirect("FileUpload_VanBanChuaDuyet.aspx");
    }
    protected void btnDongY_Click(object sender, EventArgs e)
    {
        //Kiem tra rong
        MyTextBox myTextBox = new MyTextBox();

        MyDropDownList myDropDownList = new MyDropDownList();

        if (myTextBox.kiemtraRong(txtSoVanBan) == true)
        {
            Alert.Show("So van ban khong duoc rong");

            return;
        }

        if (myTextBox.kiemtraRong(txtTenVanBan) == true)
        {
            Alert.Show("Ten van ban khong duoc rong");

            return;
        }

        if (cmbMaLoaiVanBan.Text == string.Empty)
        {
            Alert.Show("Loai van ban khong duoc rong");

            return;
        }

        if (cmbMaHinhThuc.Text == string.Empty)
        {
            Alert.Show("Hinh thuc khong duoc rong");

            return;
        }

        if (cmbMaTinhChat.Text == string.Empty)
        {
            Alert.Show("Tinh chat khong duoc rong");

            return;
        }

        if (myTextBox.kiemtraRong(txtNgayHieuLuc) == true)
        {
            txtNgayHieuLuc.Text = DateTime.Now.Date.ToString();
        }

        if (myTextBox.kiemtraRong(txtNgayHetHieuLuc) == true)
        {
            txtNgayHetHieuLuc.Text = DateTime.Now.Date.ToString();
        }

        //Kiem tra txtNgayHetHieuLuc.Text >= txtNgayHieuLuc.Text
        if (DateTime.ParseExact(txtNgayHetHieuLuc.Text, "dd/MM/yyyy", null) < DateTime.ParseExact(txtNgayHieuLuc.Text, "dd/MM/yyyy", null))
        {
            Alert.Show("Ngay chi nhanh nhan van ban khong duoc nho hon Ngay phat hanh van ban");

            return;
        }

        if (myTextBox.kiemtraRong(txtNoiDungVanBan) == true)
        {
            Alert.Show("Noi dung van ban khong duoc rong");

            return;
        }

        if (myTextBox.kiemtraRong(txtNoiDungButPhe) == true)
        {
            Alert.Show("Noi dung but phe khong duoc rong");

            return;
        }

        if (chkToanChiNhanh.Checked == false && chkPhong.Checked == false)
        {
            Alert.Show("Xin vui long chon noi nhan van ban");

            return;
        }

        VanBanBUS vbBUS = new VanBanBUS();

        VanBan vbDTO = new VanBan();

        string maVanBanMax;
        if (vbBUS.layMaVanBanMax() != null || vbBUS.layMaVanBanMax() != string.Empty)
        {
            maVanBanMax = Convert.ToString(Convert.ToInt32(vbBUS.layMaVanBanMax()) + 1);
            vbDTO.MaVanBan = DateTime.Now.Date.Year.ToString() + maVanBanMax.ToString();
            if (vbDTO.MaVanBan.Length < 10)
            {
                //Viet ham them so luong "so 0" con thieu vao maVanBanMax
                int soLuong = 10 - vbDTO.MaVanBan.Length;
                maVanBanMax = themSo0(soLuong) + maVanBanMax;
                vbDTO.MaVanBan = DateTime.Now.Date.Year.ToString() + maVanBanMax;
            }
        }
        else
        {
            maVanBanMax = "000000";
            vbDTO.MaVanBan = DateTime.Now.Date.Year.ToString() + maVanBanMax;
        }

        vbDTO.SoVanBan = txtSoVanBan.Text.ToUpper();

        if (chkToanChiNhanh.Checked)
        {
            vbDTO.MaPhamVi = "CN";
        }

        if (chkPhong.Checked)
        {
            vbDTO.MaPhamVi = "PT";
        }

        vbDTO.TenVanBan = txtTenVanBan.Text;
        vbDTO.TenFile = "(" + DateTime.Now.ToString("ddMMyyyy_hhmmss") + ")" + fupdTenFile.PostedFile.FileName;
        vbDTO.MaLoaiVanBan = cmbMaLoaiVanBan.SelectedValue.ToString();
        vbDTO.MaHinhThuc = cmbMaHinhThuc.SelectedValue.ToString();
        vbDTO.MaNoiPhatHanh = cmbMaNoiPhatHanh.SelectedValue.ToString();
        vbDTO.TenDonViSoanThao = txtTenDonViSoanThao.Text.ToUpper();
        vbDTO.MaTinhChat = cmbMaTinhChat.SelectedValue.ToString();
        vbDTO.MaTrangThai = "CD";
        vbDTO.NgayHieuLuc = DateTime.ParseExact(txtNgayHieuLuc.Text, "dd/MM/yyyy", null);
        vbDTO.NgayHetHieuLuc = DateTime.ParseExact(txtNgayHetHieuLuc.Text, "dd/MM/yyyy", null);
        vbDTO.NoiDungVanBan = txtNoiDungVanBan.Text;
        vbDTO.NoiDungButPhe = txtNoiDungButPhe.Text;
        vbDTO.MaNguoiSoanThao = (String)Session["MaNguoiDung"];
        vbDTO.NgaySoanThao = DateTime.Now;

        if (vbDTO.NgayHetHieuLuc < vbDTO.NgayHieuLuc)
        {
            Alert.Show("Ngay het hieu luc khong duoc nho hon Ngay hieu luc");

            return;
        }

        if (chkPhong.Checked)
        {
            if (gvPhongNhanVanBan.Rows.Count <= 0)
            {
                Alert.Show("Chua chon nguoi de gui van ban");

                return;
            }
        }

        //Sua
        if (vbBUS.kiemtraTonTaiSoVanBan(vbDTO.SoVanBan, cmbMaNoiPhatHanh.SelectedValue.ToString()) == false)
        {   
            vbBUS.suaVanBan(vbDTO,hfSoVanBanCanTim.Value.ToString());

            if (fupdTenFile.PostedFile.FileName != string.Empty)
            {
                uploadFile();
            }
        }
        else
        {
            Alert.Show("Da ton tai so van ban nay");

            txtSoVanBan.Text = string.Empty;

            return;
        }
        //*****

        //*****DOAN CODE NAY DUNG DE THEM VAO TABLE NOINHAN*****
        NguoiDungBUS ndBUS = new NguoiDungBUS();
        ndBUS.themMaNguoiNhanVanBan(gvPhongNhanVanBan, txtSoVanBan);

        Alert.Show("Da sua thanh cong");

        //Xoa TextBox
        myTextBox.Xoa(txtSoVanBan);
        myTextBox.Xoa(txtTenVanBan);
        //myTextBox.Xoa(txtTenFile);
        //myTextBox.Xoa(txtTenDonViSoanThao);
        myTextBox.Xoa(txtNgayHieuLuc);
        myTextBox.Xoa(txtNgayHetHieuLuc);
        myTextBox.Xoa(txtNoiDungVanBan);
        myTextBox.Xoa(txtNoiDungButPhe);
    }
    protected void btnDong_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/pHome.aspx");
    }
    protected string themSo0(int soLuong)
    {
        string temp = string.Empty;
        for (int i = 0; i < soLuong; i++)
        {
            temp += "0";
        }

        return temp;
    }
    /*protected string taoSoVanBan(TextBox textBox)
    {
        PhongBUS pBUS = new PhongBUS();
        string maNguoiDung = (String)Session["MaNguoiDung"];
        string maPhong = pBUS.layMaPhongTheoMaNguoiDung(maNguoiDung);
        string maLoaiVanBan = drplstMaLoaiVanBan.SelectedValue.ToString();

        if (textBox.Text.Length < 4)
        {
            int soLuong = 4 - textBox.Text.Length;
            textBox.Text = themSo0(soLuong) + textBox.Text;
        }

        return ((textBox.Text += "/" + maLoaiVanBan + "-" + maPhong).ToUpper());
    }*/
    protected void chkToanChiNhanh_CheckedChanged(object sender, EventArgs e)
    {
        chkPhong.Checked = false;
        gvPhongNhanVanBan.Enabled = false;

        for (int i = 0; i < gvPhongNhanVanBan.Rows.Count; i++)
        {
            CheckBox _checkBox = (CheckBox)(gvPhongNhanVanBan.Rows[i].Cells[0].FindControl("chkMaPhong"));
            if (_checkBox.Checked == true)
            {
                _checkBox.Checked = false;
            }
        }
    }
    protected void chkPhong_CheckedChanged(object sender, EventArgs e)
    {
        if (chkPhong.Checked)
        {
            chkToanChiNhanh.Checked = false;

            gvPhongNhanVanBan.Enabled = true;
        }
        else
        {
            for (int i = 0; i < gvPhongNhanVanBan.Rows.Count; i++)
            {
                CheckBox _checkBox = (CheckBox)(gvPhongNhanVanBan.Rows[i].Cells[0].FindControl("chkMaPhong"));
                if (_checkBox.Checked == true)
                {
                    _checkBox.Checked = false;
                }
            }

            gvPhongNhanVanBan.Enabled = false;
        }
    }
    protected void btnTimKiem_Click(object sender, EventArgs e)
    {
        try
        {
            MyTextBox myTextBox = new MyTextBox();
            myTextBox.Xoa(txtSoVanBan);
            myTextBox.Xoa(txtTenVanBan);
            //myTextBox.Xoa(txtTenFile);
            myTextBox.Xoa(txtNgayHieuLuc);
            myTextBox.Xoa(txtNgayHetHieuLuc);
            myTextBox.Xoa(txtTenDonViSoanThao);
            myTextBox.Xoa(txtNoiDungVanBan);
            myTextBox.Xoa(txtNoiDungButPhe);

            PhongBUS pBUS = new PhongBUS();
            string maNguoiDung = (String)Session["MaNguoiDung"];
            string maPhong = pBUS.layMaPhongTheoMaNguoiDung(maNguoiDung);

            VanBanBUS vbBUS = new VanBanBUS();
            txtSoVanBanCanTim.Text = txtSoVanBanCanTim.Text.ToUpper();
            string soVanBan = txtSoVanBanCanTim.Text;

            bool kiemtra = vbBUS.kiemtraTonTaiSoVanBanCanTim(soVanBan, maPhong);
            if (kiemtra == true)
            {
                chkToanChiNhanh.Checked = false;
                chkPhong.Checked = false;
                
                hfSoVanBanCanTim.Value = txtSoVanBanCanTim.Text;

                txtSoVanBan.Text = txtSoVanBanCanTim.Text;
                txtTenVanBan.Text = vbBUS.layTenVanBanCanTim(soVanBan, maPhong);
                lblTenFile.Text = vbBUS.layTenFileCanTim(soVanBan, maPhong);

                string maLoaiVanBan = vbBUS.layMaLoaiVanBan(soVanBan, maPhong);
                cmbMaLoaiVanBan.SelectedValue = maLoaiVanBan;

                string maHinhThuc = vbBUS.layMaHinhThuc(soVanBan, maPhong);
                cmbMaHinhThuc.SelectedValue = maHinhThuc;

                string maNoiPhatHanh = vbBUS.layMaNoiPhatHanh(soVanBan, maPhong);
                cmbMaNoiPhatHanh.SelectedValue = maNoiPhatHanh;

                string tenDonViSoanThao = vbBUS.layTenDonViSoanThao(soVanBan, maPhong);
                txtTenDonViSoanThao.Text = tenDonViSoanThao;

                string maTinhChat = vbBUS.layMaTinhChat(soVanBan, maPhong);
                cmbMaTinhChat.SelectedValue = maTinhChat;

                string ngayHieuLuc = vbBUS.layNgayHieuLuc(soVanBan, maPhong);
                txtNgayHieuLuc.Text = ngayHieuLuc;
                if (txtNgayHieuLuc.Text.Length > 10)
                {
                    txtNgayHieuLuc.Text = txtNgayHieuLuc.Text.Substring(0, 10);
                }

                string ngayHetHieuLuc = vbBUS.layNgayHetHieuLuc(soVanBan, maPhong);
                txtNgayHetHieuLuc.Text = ngayHetHieuLuc;
                if (txtNgayHetHieuLuc.Text.Length > 10)
                {
                txtNgayHetHieuLuc.Text = txtNgayHetHieuLuc.Text.Substring(0, 10);
                }

                string noiDungVanBan = vbBUS.layNoiDungVanBan(soVanBan, maPhong);
                txtNoiDungVanBan.Text = noiDungVanBan;

                string noiDungButPhe = vbBUS.layNoiDungButPhe(soVanBan, maPhong);
                txtNoiDungButPhe.Text = noiDungButPhe;

                PhamViBUS pvBUS = new PhamViBUS();
                string maPhamVi = pvBUS.layMaPhamViTheoSoVanBanMaPhong(soVanBan, maPhong);
                if (maPhamVi == "CN")
                {
                    chkToanChiNhanh.Checked = true;
                }
                if (maPhamVi == "PT")
                {
                    chkPhong.Checked = true;
                    gvPhongNhanVanBan.Enabled = true;
                    
                    //Gan du lieu len gvPhongNhanVanBan
                    gvPhongNhanVanBan.DataSource = pBUS.layDanhSachPhong();
                    gvPhongNhanVanBan.DataBind();
                }
            }

            return;
        }
        catch
        {
            Alert.Show("Khong tim thay so van ban nay");

            return;
        }
    }
    protected void btnSua_Click(object sender, EventArgs e)
    {
        //Kiem tra rong
        MyTextBox myTextBox = new MyTextBox();

        MyDropDownList myDropDownList = new MyDropDownList();

        if (myTextBox.kiemtraRong(txtSoVanBan) == true)
        {
            Alert.Show("So van ban khong duoc rong");

            return;
        }

        if (myTextBox.kiemtraRong(txtTenVanBan) == true)
        {
            Alert.Show("Ten van ban khong duoc rong");

            return;
        }

        if (cmbMaLoaiVanBan.Text == string.Empty)
        {
            Alert.Show("Loai van ban khong duoc rong");

            return;
        }

        if (cmbMaHinhThuc.Text == string.Empty)
        {
            Alert.Show("Hinh thuc khong duoc rong");

            return;
        }

        if (cmbMaTinhChat.Text == string.Empty)
        {
            Alert.Show("Tinh chat khong duoc rong");

            return;
        }

        if (myTextBox.kiemtraRong(txtNgayHieuLuc) == true)
        {
            txtNgayHieuLuc.Text = DateTime.Now.Date.ToString();
        }

        if (myTextBox.kiemtraRong(txtNgayHetHieuLuc) == true)
        {
            txtNgayHetHieuLuc.Text = DateTime.Now.Date.ToString();
        }

        //Kiem tra txtNgayHetHieuLuc.Text >= txtNgayHieuLuc.Text
        if (DateTime.ParseExact(txtNgayHetHieuLuc.Text, "dd/MM/yyyy", null) < DateTime.ParseExact(txtNgayHieuLuc.Text, "dd/MM/yyyy", null))
        {
            Alert.Show("Ngay chi nhanh nhan van ban khong duoc nho hon Ngay phat hanh van ban");

            return;
        }

        if (myTextBox.kiemtraRong(txtNoiDungVanBan) == true)
        {
            Alert.Show("Noi dung van ban khong duoc rong");

            return;
        }

        if (myTextBox.kiemtraRong(txtNoiDungButPhe) == true)
        {
            Alert.Show("Noi dung but phe khong duoc rong");

            return;
        }

        if (chkToanChiNhanh.Checked == false && chkPhong.Checked == false)
        {
            Alert.Show("Xin vui long chon noi nhan van ban");

            return;
        }

        VanBanBUS vbBUS = new VanBanBUS();

        VanBan vbDTO = new VanBan();

        string maVanBanMax;
        if (vbBUS.layMaVanBanMax() != null || vbBUS.layMaVanBanMax() != string.Empty)
        {
            maVanBanMax = Convert.ToString(Convert.ToInt32(vbBUS.layMaVanBanMax()) + 1);
            vbDTO.MaVanBan = DateTime.Now.Date.Year.ToString() + maVanBanMax.ToString();
            if (vbDTO.MaVanBan.Length < 10)
            {
                //Viet ham them so luong "so 0" con thieu vao maVanBanMax
                int soLuong = 10 - vbDTO.MaVanBan.Length;
                maVanBanMax = themSo0(soLuong) + maVanBanMax;
                vbDTO.MaVanBan = DateTime.Now.Date.Year.ToString() + maVanBanMax;
            }
        }
        else
        {
            maVanBanMax = "000000";
            vbDTO.MaVanBan = DateTime.Now.Date.Year.ToString() + maVanBanMax;
        }

        vbDTO.SoVanBan = txtSoVanBan.Text.ToUpper();

        if (chkToanChiNhanh.Checked)
        {
            vbDTO.MaPhamVi = "CN";
        }

        if (chkPhong.Checked)
        {
            vbDTO.MaPhamVi = "PT";
        }

        vbDTO.TenVanBan = txtTenVanBan.Text;
        if (fupdTenFile.PostedFile.FileName != string.Empty)
        {
            vbDTO.TenFile = "(" + DateTime.Now.ToString("ddMMyyyy_hhmmss") + ")" + fupdTenFile.PostedFile.FileName;
        }
        else
        {
            vbDTO.TenFile = lblTenFile.Text;
        }
        vbDTO.MaLoaiVanBan = cmbMaLoaiVanBan.SelectedValue.ToString();
        vbDTO.MaHinhThuc = cmbMaHinhThuc.SelectedValue.ToString();
        vbDTO.MaNoiPhatHanh = cmbMaNoiPhatHanh.SelectedValue.ToString();
        vbDTO.TenDonViSoanThao = txtTenDonViSoanThao.Text.ToUpper();
        vbDTO.MaTinhChat = cmbMaTinhChat.SelectedValue.ToString();
        vbDTO.MaTrangThai = "CD";
        vbDTO.NgayHieuLuc = DateTime.ParseExact(txtNgayHieuLuc.Text, "dd/MM/yyyy", null);
        vbDTO.NgayHetHieuLuc = DateTime.ParseExact(txtNgayHetHieuLuc.Text, "dd/MM/yyyy", null);
        vbDTO.NoiDungVanBan = txtNoiDungVanBan.Text;
        vbDTO.NoiDungButPhe = txtNoiDungButPhe.Text;
        vbDTO.MaNguoiSoanThao = (String)Session["MaNguoiDung"];
        vbDTO.NgaySoanThao = DateTime.Now;

        if (vbDTO.NgayHetHieuLuc < vbDTO.NgayHieuLuc)
        {
            Alert.Show("Ngay het hieu luc khong duoc nho hon Ngay hieu luc");

            return;
        }

        if (chkPhong.Checked)
        {
            if (gvPhongNhanVanBan.Rows.Count <= 0)
            {
                Alert.Show("Chua chon nguoi de gui van ban");

                return;
            }
        }

        //Xoa truoc khi them vao table NoiNhan
        NoiNhan nnDTO = new NoiNhan();
        nnDTO.MaVanBan = vbBUS.layMaVanBanMaxVuaThemVao(txtSoVanBan.Text);
        NoiNhanBUS nnBUS = new NoiNhanBUS();
        nnBUS.xoaNoiNhanTheoMaVanBan(nnDTO);
        
        //Sua
        vbBUS.suaVanBan(vbDTO, hfSoVanBanCanTim.Value);

        if (fupdTenFile.PostedFile.FileName != string.Empty)
        {
            uploadFile();
        }
        //*****

        //*****DOAN CODE NAY DUNG DE THEM VAO TABLE NOINHAN*****
        NguoiDungBUS ndBUS = new NguoiDungBUS();
        ndBUS.themMaNguoiNhanVanBan(gvPhongNhanVanBan, txtSoVanBan);

        Alert.Show("Da sua thanh cong");

        //Xoa TextBox
        myTextBox.Xoa(txtSoVanBan);
        myTextBox.Xoa(txtTenVanBan);
        //myTextBox.Xoa(txtTenFile);
        //myTextBox.Xoa(txtTenDonViSoanThao);
        myTextBox.Xoa(txtNgayHieuLuc);
        myTextBox.Xoa(txtNgayHetHieuLuc);
        myTextBox.Xoa(txtNoiDungVanBan);
        myTextBox.Xoa(txtNoiDungButPhe);
    }
    protected void gvPhongNhanVanBan_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvPhongNhanVanBan.PageIndex = e.NewPageIndex;
        
        layDanhSachPhong();
    }
    protected int kiemtraCoCheckVaoCheckBox()
    {
        int dem = 0;
        for (int i = 0; i < gvPhongNhanVanBan.Rows.Count; i++)
        {
            CheckBox _checkBox = (CheckBox)(gvPhongNhanVanBan.Rows[i].Cells[0].FindControl("chkMaPhong"));
            if (_checkBox.Checked)
            {
                dem += 1;
            }
        }

        return dem;
    }
    protected void cmbMaNoiPhatHanh_SelectedIndexChanged(object sender, EventArgs e)
    {
        layThongTinChiTietMaNoiPhatHanh();
    }
    private void layThongTinChiTietMaNoiPhatHanh()
    {
        NoiPhatHanh nphDTO = new NoiPhatHanh();
        nphDTO.MaNoiPhatHanh = cmbMaNoiPhatHanh.SelectedValue;

        NoiPhatHanhBUS nphBUS = new NoiPhatHanhBUS();

        IList<NoiPhatHanh> lstThongTinNoiPhatHanh = nphBUS.layThongTinNoiPhatHanhTheoMaNoiPhatHanh(nphDTO);
        switch (nphDTO.MaNoiPhatHanh)
        {
            case "BIDV":
                txtTenDonViSoanThao.Text = "BIDV";
                break;
            case "BIDVCM":
                txtTenDonViSoanThao.Text = "BIDV CAMAU";
                break;
            case "PT":
                txtTenDonViSoanThao.Text = "BIDV CAMAU";
                break;
            default:
                txtTenDonViSoanThao.Text = string.Empty;
                break;
        }
    }
    private void uploadFile()
    {
        string path = Server.MapPath("..//VanBanLuuTru");

        path += "/" + "(" + DateTime.Now.ToString("ddMMyyyy_hhmmss") + ")" + fupdTenFile.PostedFile.FileName;

        fupdTenFile.PostedFile.SaveAs(path);
    }
}